import React from 'react'
import { useRoutes } from 'react-router-dom'

/**
 * React.lazy 懒加载
 * 使组件动态导入
 */
const Login = React.lazy(() => import('@/views/login/index'))
const Layout = React.lazy(() => import('@/layout/layOut'))
const Profile = React.lazy(() => import('@/views/profile/index'))
const TodoList = React.lazy(() => import('@/views/todoList/index'))

function MyRoute() {
    let element = useRoutes([
        {
            path: '/login',
            element: <Login />
        },
        {
            path: '/',
            element: <Layout />,
            children: [
                {
                    path: 'profile',
                    element: <Profile />
                },
                {
                    path: 'todolist',
                    element: <TodoList />
                }
            ]
        }
    ])

    return element
}

export default MyRoute
